/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Inicial.java
 *
 * Created on 26-jun-2011, 15:19:30
 */

package guiAdministracion;

import javax.swing.JOptionPane;
import logica.Fabrica;
import logica.IAdministracion;

/**
 *
 * @author Ernesto
 */
public class Inicial extends javax.swing.JFrame {

    private AltaCliente frameClientes;
    private AltaFuncionPelicula framePeliculaFuncion;

    public Inicial() {
        initComponents();

        frameClientes= new AltaCliente();
        framePeliculaFuncion= new AltaFuncionPelicula();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        btnFrameClientes = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        btnFramePeliculaFuncion = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        btnGuardar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("ADMINISTRACION");
        setMinimumSize(new java.awt.Dimension(450, 350));
        getContentPane().setLayout(new java.awt.FlowLayout());

        jPanel2.setMaximumSize(new java.awt.Dimension(600, 600));
        jPanel2.setLayout(new java.awt.GridLayout(7, 1));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 42, Short.MAX_VALUE)
        );

        jPanel2.add(jPanel1);

        btnFrameClientes.setText("Mantenimiento de Clientes");
        btnFrameClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFrameClientesActionPerformed(evt);
            }
        });
        jPanel2.add(btnFrameClientes);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 42, Short.MAX_VALUE)
        );

        jPanel2.add(jPanel3);

        btnFramePeliculaFuncion.setText("Mantenimiento de Peliculas y Funciones");
        btnFramePeliculaFuncion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFramePeliculaFuncionActionPerformed(evt);
            }
        });
        jPanel2.add(btnFramePeliculaFuncion);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 42, Short.MAX_VALUE)
        );

        jPanel2.add(jPanel4);

        btnGuardar.setText("Guardar los Cambios");
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });
        jPanel2.add(btnGuardar);

        getContentPane().add(jPanel2);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnFrameClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFrameClientesActionPerformed

        frameClientes.setVisible(true);
    }//GEN-LAST:event_btnFrameClientesActionPerformed

    private void btnFramePeliculaFuncionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFramePeliculaFuncionActionPerformed

        framePeliculaFuncion.setVisible(true);
    }//GEN-LAST:event_btnFramePeliculaFuncionActionPerformed

    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed

        int resultado= 0;

        try{
            IAdministracion iadmin= Fabrica.getIAdministracion();
            resultado= iadmin.guardarAdministracion();

        }catch(Exception e){

            JOptionPane.showMessageDialog(null, e.getMessage());
        }

        if(resultado == 3)
            JOptionPane.showMessageDialog(null, "Se han guardado los cambios");

        else
            JOptionPane.showMessageDialog(null, "Alguno de los cambios no pudo guardarse");

    }//GEN-LAST:event_btnGuardarActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Inicial().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnFrameClientes;
    private javax.swing.JButton btnFramePeliculaFuncion;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    // End of variables declaration//GEN-END:variables

}
